/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI.DoctorManage;

import GUI.MainFunction;
import connection.ManLabConnection;
import entities.DoctorDetails;
import java.util.ArrayList;
import javax.swing.JOptionPane;

/**
 *
 * @author Admin
 */
public class DeleteDoctor {

    private ArrayList<DoctorDetails> doctorDetailses;
    private DoctorDetails doctorDetails;
    private MainFunction parentFrame;
    private ManLabConnection cnn;
    private ArrayList<String> qry;

    public DeleteDoctor(ArrayList<DoctorDetails> doctorDetailses, DoctorDetails doctorDetails, MainFunction parentFrame) {
        this.doctorDetailses = doctorDetailses;
        this.doctorDetails = doctorDetails;
        this.parentFrame = parentFrame;
        this.cnn = new ManLabConnection();
        this.qry = new ArrayList<String>();
    }

    public void deleteDoctor() {
        int dID = doctorDetails.getdID();
boolean cn=        cnn.createConnection();
        String qry1 = "delete from Report where dID=" + dID + "";
        qry.add(qry1);
        String qry2 = "delete from DoctorDetail where dID=" + dID + "";
        qry.add(qry2);
        for (String s : qry) {
            cnn.executeQuery(s);
        }
        cnn.closeConnection();
        doctorDetailses.remove(doctorDetails);
        JOptionPane.showMessageDialog(parentFrame, "Deleted successfully");
        this.parentFrame.refreshReportTableView();
    }
}
